package com.dianrui.qiyouriding.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;


import com.dianrui.qiyouriding.R;
import com.dianrui.qiyouriding.update.DefaultUpdateParser;
import com.dianrui.qiyouriding.util.MyUtil;
import com.dianrui.qiyouriding.util.Url;
import com.xuexiang.xupdate.XUpdate;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 关于
 * @author lzy
 */
public class AboutActivity extends BaseActivity {

    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.ver)
    TextView ver;


    @Override
    public int getContentViewId() {
        return R.layout.activity_about;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void initView() {
        title.setText(getString(R.string.about));
        customInit(true, R.color.main_color);
        ver.setText(MyUtil.getAppVersionName(AboutActivity.this));
    }

    @Override
    public void initData() {

    }

    @OnClick({R.id.back, R.id.click_update, R.id.click_info, R.id.txt1, R.id.txt2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.click_info:
                startActivity(new Intent(AboutActivity.this, WebViewActivity.class).putExtra("type", "info"));
                break;
            case R.id.txt1:
                startActivity(new Intent(AboutActivity.this, WebViewActivity.class).putExtra("type", "software"));
                break;

            case R.id.txt2:
                startActivity(new Intent(AboutActivity.this, WebViewActivity.class).putExtra("type", "secret"));
                break;
            //更新
            case R.id.click_update:
                XUpdate.newBuild(AboutActivity.this).updateUrl(Url.BASE_URL+"/api.php/Apply/update/version_code/" + MyUtil.getVersionName(AboutActivity.this) + "/apply_type/1").themeColor(getResources().getColor(R.color.main_color))
                        .updateParser(new DefaultUpdateParser()).update();
            default:
                break;

        }
    }




}
